home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: question assignment operator in c++
- Date: 7 Mar 1996 19:27:08 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4hndac$mgj@dawn.mmm.com>
- References: <menghua_wang.1.002DB7BE@muccmail.missouri.edu>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- menghua wang (menghua_wang@muccmail.missouri.edu) wrote:
- > I do not why the assignment operator can only be overloaded as a member
- > function in a class such as:
-
- > class myclass {
- > int i;
- > public:
- > myclass operator= (myclass &A) {
- > i = A.i;
- > return *this;
- > }
- > };
-
- > Why does not the following frind overloading work?
-
- > mycalss operator= (myclass &A, myclass &B) {
- > A.i = B.i;
- > return A;
- > }
-
- Because the [April draft] standard says that
- An assignment operator shall be implemented by a non-static member
- function with exactly one parameter.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-